package cn.afactory.tygz.model;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created with Android Studio.
 * Title:SecondGoodsInfo
 * Description:
 * Copyright:Copyright (c) 2015
 * Company:和平必胜、正义必胜、人民必胜
 * Author:炎黄子孙
 * Date:15/9/11
 * Time:下午3:44
 * Version 1.0
 */
public class ServiceType implements Serializable{
    private static final long serialVersionUID = 3246451692600706144L;

    public int typeId;

    public String typeName;


    /**
     * 反序列化函数，用于从json字符串反序列化本类型实例
     */
    public static ServiceType deserialize(String json) throws JSONException {
        if (json != null && !json.isEmpty()) {
            return deserialize(new JSONObject(json));
        }
        return null;
    }

    /**
     * 反序列化函数，用于从json节点对象反序列化本类型实例
     */
    public static ServiceType deserialize(JSONObject json) throws JSONException {
        if (json != null && json != JSONObject.NULL && json.length() > 0) {
            ServiceType result = new ServiceType();

            result.typeId = json.optInt("typeId");

            if (!json.isNull("typeName")) {
                result.typeName = json.optString("typeName", null);
            }
            return result;
        }
        return null;
    }
}
